package com.ewei.web.common.shiro.xmemcached;

import net.rubyeye.xmemcached.XMemcachedClient;

import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.cache.CacheManager;

public class XmemcahedManager implements CacheManager{
	
	private XMemcachedClient client;
	private XmemcachedCache cache;
	
	public XMemcachedClient getClient() {
		return client;
	}

	public void setClient(XMemcachedClient client) {
		this.client = client;
		cache = new XmemcachedCache(client);
	}

	@SuppressWarnings("unchecked")
	@Override
	public <K, V> Cache<K, V> getCache(String name) throws CacheException {
		return (Cache<K, V>) cache;
	}

}
